# -*- coding: utf-8 -*-
from sqlalchemy import Column, Integer, String, DateTime, func
import datetime
from utils.work_db import Base

# 消息类型 1:系统消息 2:简历回执(投递后简历) 3:发布职位
MESSAGE_TYPE = {
    1: '系统消息',
    2: '简历回执',
    3: '发布工作'
}


class UserMessage(Base):
    __tablename__ = 'user_message'
    message_id = Column(Integer, primary_key=True, autoincrement=True)
    message_type = Column(Integer, default=1)
    message_date = Column(String)
    company_id = Column(Integer)
    company_name = Column(String)
    user_id = Column(Integer)
    user_name = Column(String)
    status = Column(Integer, default=1)
    content = Column(String)
    create_time = Column(DateTime, default=func.now())
    update_time = Column(DateTime, default=func.now())
    job_id = Column(Integer)
    is_read = Column(Integer, default=0)
    create_userid = Column(Integer)
    read_time = Column(DateTime)

    def json(self):
        return {
            'message_id': self.message_id,
            'message_type': self.message_type,
            'message_date': self.message_date,
            'company_id': self.company_id,
            'company_name': self.company_name,
            'user_id': self.user_id,
            'user_name': self.user_name,
            'content': self.content,
            'job_id': self.job_id,
            'is_read': self.is_read
        }
